{% extends 'blank.html.twig' %}
{% block pagecss %}
    {{ parent() }}
    <style rel="stylesheet" type="text/css">
        /*表格css*/
        *{padding:0;margin:0;}
        tr:hover{background:rgba(100,100,200,0.2);}
        td{border:1px solid rgba(100,100,100,0.3);border-top:none;}
        /*这是分页页码的style*/
        #pagecode{width:800px;line-height:30px;text-align:center;}
        .code_block{display:inline-block;width:30px;height:30px;background:rgba(220,220,100,0.5);margin-left:20px;border:1px solid rgba(0,0,0,0.2);}
        #code_form{display:inline-block;width:120px;}
        .code_button{width:32px;height:32px;}
        .code_button:hover{cursor:pointer;}
    </style>
{% endblock %}

{% block jsscript %}
    {{ parent() }}
{% endblock %}

{% block body %}
    {% block header %}
        {{ parent() }}
        <table>
            <tr class="thead text-c">
                <td width="100"  height="50">序号</td>
                <td width="200">字段名</td>
                <td width="300">描述</td>
                <td width="200">操作</td>
            </tr>
            {% for field in fieldArr %}
                <tr class="tbody text-c">
                    <td height="50">{{ loop.index }}</td>
                    <td>{{ field }}</td>
                    <td></td>
                    <td>
                        <a class="aaa">修改</a>
                        <a>删除</a>
                    </td>
                </tr>
            {% endfor %}
        </table>
        {% if list_len>per %}
            <div id="pagecode">
                {#计算最大页码#}
                {% if list_len%per == 0 %}
                    {% if list_len!=0 %}
                        {% set maxpage = list_len//per %}
                    {% else %}
                        {% set maxpage = 1 %}
                    {% endif %}
                {% else %}
                    {% set maxpage = list_len//per + 1 %}
                {% endif %}
                {#根据当前页生成页码链接#}
                {% if maxpage>=5 %}
                    {% if page <=3 %}
                        {% for i in 1..5 %}
                            <a class="code_block" href="/AbsSR/web/app_dev.php/dic_bundle/dic_field?page={{ i }}&table_name={{ table_name }}">{{ i }}</a>
                        {% endfor %}
                    {% elseif page >= maxpage - 2 %}
                        {% for i in 1..5 %}
                            <a class="code_block" href="/AbsSR/web/app_dev.php/dic_bundle/dic_field?page={{ maxpage -5 + i }}&table_name={{ table_name }}">{{ maxpage -5 + i }}</a>
                        {% endfor %}
                    {% else %}
                        {% for i in 1..5 %}
                            <a class="code_block" href="/AbsSR/web/app_dev.php/dic_bundle/dic_field?page={{ page -3 + i }}&table_name={{ table_name }}">{{ page -3 + i }}</a>
                        {% endfor %}
                    {% endif %}
                {% else %}
                    {% for i in 1..maxpage %}
                        <a class="code_block" href="/AbsSR/web/app_dev.php/dic_bundle/dic_field?page={{ i }}&table_name={{ table_name }}">{{ i }}</a>
                    {% endfor %}
                {% endif %}
                <form id="code_form" action="/AbsSR/web/app_dev.php/dic_bundle/dic_field" method="get">
                    <input class="code_block code_button" type="submit"  value="转到"/><input type="hidden" value="{{ table_name }}" name="table_name">
                    <input class="code_block" placeholder="页码" value="" name="page" onkeyup="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')" />
                </form>
            </div>
        {% endif %}
    {% endblock %}

    {% block menu %}
        {{ parent() }}
    {% endblock %}

    {% block section %}
        {{ parent() }}
    {% endblock %}

{% endblock %}

{% block footer %}
    {{ parent() }}
{% endblock %}


